/*
 * PaySuccessHolder.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.response.QueryOrderResultResponse;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.TextRenderUtils;
import com.yidiandao.business.utils.UIUtils;

/**
 * 订单支付/购买成功-ViewHolder
 * <p>
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/21 16:13
 */
public class PaySuccessHolder extends ViewHolder {

    public TextView tvShowOrder;
    public TextView tvContinueBuy;
    private TextView tvOrderMoney;
    private TextView tvPaySuccess;

    @Override
    protected void initView(View rootView) {
        tvOrderMoney = (TextView) rootView.findViewById(R.id.tv_order_money);
        tvShowOrder = (TextView) rootView.findViewById(R.id.tv_show_order);
        tvContinueBuy = (TextView) rootView.findViewById(R.id.tv_continue_buy);
        tvPaySuccess = (TextView) rootView.findViewById(R.id.tv_pay_success);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_pay_success;
    }

    public void refreshUI(QueryOrderResultResponse.Data data) {
        tvPaySuccess.setText(data.getPayTitle());
        tvOrderMoney.setText(getTotalMoney(data.getPayAmount()));
    }

    private SpannableStringBuilder getTotalMoney(String price) {
        SpannableStringBuilder builder = new SpannableStringBuilder();
        SpannableString pre = TextRenderUtils.getAppearanceText(UIUtils.getString(R.string.total_money), R.style.PayResultStyle);
        SpannableString money = TextRenderUtils.getBeautyPrice(price, null, UIUtils.dp2px(13), UIUtils.dp2px(11));
        builder.append(pre);
        builder.append(money);

        return builder;
    }
}
